package com.comsoftstar.nt5s.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hzc.nt5s.R;
import com.hzc.nt5s.bean.Regulations;

import java.util.List;

public class RegulationsDataAdapter extends BaseAdapter {
    private List<Regulations> mList;
    private Context mContext;

    public RegulationsDataAdapter(Context context, List<Regulations> list) {
        mList = list;
        this.mContext = context;
    }
    @Override
    public int getCount() {

        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {

        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        Regulations rs = mList.get(position);
        if (convertView==null){
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.regulations_item, null);
            viewHolder.regulationNo= (TextView) convertView.findViewById(R.id.regulations_item_regulationNo);
            viewHolder.standard= (TextView) convertView.findViewById(R.id.regulations_item_standard);
            viewHolder.cardNum= (TextView) convertView.findViewById(R.id.regulations_item_cardNum);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.regulationNo.setText(rs.getRegulationNo());
        viewHolder.standard.setText(rs.getStandard());
        viewHolder.cardNum.setText(rs.getCardNum());
        return convertView;
    }
    class ViewHolder {
        TextView regulationNo, standard, cardNum;
    }

}
